package com.usian.article.controller;

import com.alibaba.fastjson.JSON;
import com.usian.apis.article.AuthorControllerApi;
import com.usian.article.service.AuthorService;
import com.usian.model.article.pojos.ApAuthor;
import com.usian.model.common.dtos.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author baimugudu
 * @email 2415621370@qq.com
 * @date 2023/8/25 8:40
 */
@RestController
@RequestMapping("author")
@Slf4j
public class AuthorController implements AuthorControllerApi {

    @Autowired AuthorService authorService;

    @Override
    @GetMapping("/findByUserid/{id}")
    public ApAuthor findByUserid(@PathVariable Integer id) {
        return authorService.findByUserid(id);
    }

    @Override
    @PostMapping("save")
    public ResponseResult save(@RequestBody ApAuthor apAuthor) {
        log.info("apAuthor:{}", JSON.toJSONString(apAuthor));
        return authorService.saveApAuthor(apAuthor);
    }
}
